package com.tnt.springbootrabbmitmq.provider.fanoutexchange;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Description 扇形交换机
 * @Author zhuangxl
 * @Date 2021-01-25 20:09
 */
@Configuration
public class FanoutExchangeRabbitConfig {

    /**
     * @Description: 定义队列
     * @Author: zhuangxl
     * @Date: 21/1/25 20:21
     * @return: org.springframework.amqp.core.Queue
     **/
    @Bean
    public Queue fanoutQueue1(){

        return new Queue("fanoutQueue1");

    }

    /**
     * @Description: 定义队列
     * @Author: zhuangxl
     * @Date: 21/1/25 20:21
     * @return: org.springframework.amqp.core.Queue
     **/
    @Bean
    public Queue fanoutQueue2(){

        return new Queue("fanoutQueue2");

    }

    /**
     * @Description: 定义交换机
     * @Author: zhuangxl
     * @Date: 21/1/25 20:21
     * @return: org.springframework.amqp.core.FanoutExchange
     **/
    @Bean
    public FanoutExchange fanoutExchange(){

        return new FanoutExchange("fanoutExchange");

    }

    /**
     * @Description: 绑定队列到交换机
     * @Author: zhuangxl
     * @Date: 21/1/25 20:22
     * @return: org.springframework.amqp.core.Binding
     **/
    @Bean
    public Binding bindingExchange1(){

        return BindingBuilder.bind(fanoutQueue1()).to(fanoutExchange());

    }

    /**
     * @Description: 绑定队列到交换机
     * @Author: zhuangxl
     * @Date: 21/1/25 20:22
     * @return: org.springframework.amqp.core.Binding
     **/
    @Bean
    public Binding bindingExchange2(){

        return BindingBuilder.bind(fanoutQueue2()).to(fanoutExchange());

    }

}
